package com.mayuran19.portal.accounting.database.domain;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;

import com.mayuran19.portal.common.database.domain.DomainObject;
import com.mayuran19.portal.common.database.domain.Vendor;

@Entity(name = "expense_header")
public class ExpenseHeader extends DomainObject {
	private Long id;
	private Vendor vendor;
	private String notes;
	private String invoiceNo;
	private Date date;
	private Date dueDate;
	private TermOfPayment termOfPayment;
	private BigDecimal total = new BigDecimal(0);
	private BigDecimal tax = new BigDecimal(0);
	private BigDecimal netTotal = new BigDecimal(0);
	private List<ExpenseDetail> expenseDetails = new ArrayList<ExpenseDetail>();

	public enum ClassProperties {
		expenseDetails
	}

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "vendor_id")
	public Vendor getVendor() {
		return vendor;
	}

	public void setVendor(Vendor vendor) {
		this.vendor = vendor;
	}

	public String getNotes() {
		return notes;
	}

	public void setNotes(String notes) {
		this.notes = notes;
	}

	public String getInvoiceNo() {
		return invoiceNo;
	}

	public void setInvoiceNo(String invoiceNo) {
		this.invoiceNo = invoiceNo;
	}

	public Date getDate() {
		return date;
	}

	public void setDate(Date date) {
		this.date = date;
	}

	public Date getDueDate() {
		return dueDate;
	}

	public void setDueDate(Date dueDate) {
		this.dueDate = dueDate;
	}

	@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
	@JoinColumn(name = "term_of_payment_id")
	public TermOfPayment getTermOfPayment() {
		return termOfPayment;
	}

	public void setTermOfPayment(TermOfPayment termOfPayment) {
		this.termOfPayment = termOfPayment;
	}

	public BigDecimal getTotal() {
		return total;
	}

	public void setTotal(BigDecimal total) {
		this.total = total;
	}

	public BigDecimal getTax() {
		return tax;
	}

	public void setTax(BigDecimal tax) {
		this.tax = tax;
	}

	public BigDecimal getNetTotal() {
		return netTotal;
	}

	public void setNetTotal(BigDecimal netTotal) {
		this.netTotal = netTotal;
	}

	@OneToMany(fetch = FetchType.LAZY)
	@JoinColumn(name = "expense_header_id", insertable = false, updatable = false)
	public List<ExpenseDetail> getExpenseDetails() {
		return expenseDetails;
	}

	public void setExpenseDetails(List<ExpenseDetail> expenseDetails) {
		this.expenseDetails = expenseDetails;
	}

}
